package com.damon.jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.damon.utils.DbUtil;
/**
 * ps:查询需要被调用的存储过程
 * @author 风蚕
 *
 */
public class WmsHttpServerJdbc {
	Logger logger = LoggerFactory.getLogger(WmsHttpServerJdbc.class);
	
	private Connection conn = DbUtil.getConnection();
    private final static String  IS_OK = "1";
	public Map<String, String> getProcedureMap() {
		String sql = "select url_pattern,proc_name from wms_http_server where is_ok = ?";
		PreparedStatement preparedStatement;
		Map<String, String> map = new HashMap<String, String>();
		try {
			preparedStatement = conn.prepareStatement(sql);
			preparedStatement.setString(1, IS_OK);
			ResultSet rs = preparedStatement.executeQuery();
			while(rs.next()) {
				String urlParrern = rs.getString(1);
				String procName = rs.getString(2);
				map.put(urlParrern, procName);
			}
		} catch (SQLException e) {
			e.printStackTrace();
			logger.error("通过请求url获取存储过程名称失败！");
		}
		
		return map;
	}
}
